package com.aaa.service.impl;

import com.aaa.entity.Emp;
import com.aaa.mapper.EmpMapper;
import com.aaa.service.EmpService;
import com.aaa.vo.EmpVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Resource
    private EmpMapper empMapper;

    @Override
    public PageInfo<Emp> selectAll(Integer current, Integer pageSize, EmpVo empVo) {
        PageHelper.startPage(current, pageSize);
        List<Emp> emps = empMapper.selectAll(empVo);
        PageInfo<Emp> pageInfo = new PageInfo<>(emps);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return empMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Emp selectById(Integer id) {
        return empMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateById(Emp emp) {
        return empMapper.updateByPrimaryKey(emp);
    }

    @Override
    public int insertEmp(Emp emp) {
        int i = empMapper.insert(emp);
        return i;
    }
}
